﻿using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EtityTest
{   
    /// <summary>
    /// 数据上下文
    /// </summary>
    public class ApiDbContext:DbContext
    {
        public ApiDbContext(DbContextOptions<ApiDbContext> opts) : base(opts)
        {

        }
        /// <summary>
        /// 人员信息
        /// </summary>
        public DbSet<User> Users { get; set; }

        /// <summary>
        /// 菜谱
        /// </summary>
        public DbSet<BillFare> BillFares { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<User>().HasData([
                new User{
                    FirstName="张",
                    LastName="三",
                    Type=0,
                    Pay=10000,
                    Gender=true,
                    Age=30,
                    AddTime=DateTime.Now
                }

                ]);
            modelBuilder.Entity<BillFare>().HasData([
                new BillFare{
                    Cooker="张三",
                    Price=200,
                    Taste="麻辣",
                    Cuisine="川菜",
                    Taboo="患有胃病人员",
                    VegDishes="青椒炒土豆丝",
                    MetDishes="红烧肉"
                }

                ]);
        }
    }
}
